﻿using UnityEngine;
using BehaviorDesigner.Runtime.Tasks;
using BehaviorDesigner.Runtime;

[TaskCategory("MyActions")]
[TaskDescription("转向玩家")]
public class FaceToPlayer : Action {

	[BehaviorDesigner.Runtime.Tasks.Tooltip("朝向的目标玩家")]
	public SharedGameObject player;

	[BehaviorDesigner.Runtime.Tasks.Tooltip("自己")]
	public SharedGameObject monster;
	
	public override TaskStatus OnUpdate(){

		Vector3 targetDir = player.Value.transform.position - monster.Value.transform.position;
		monster.Value.transform.rotation = Quaternion.LookRotation(targetDir);
		return TaskStatus.Success;
	}
}
